/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package combomodel;

import eloma.classe.material.Material;
import java.util.List;
import javax.swing.AbstractListModel;
import javax.swing.ComboBoxModel;

/**
 *
 * @author icaro.klinger
 */
public class ComboBoxMaterialModel extends AbstractListModel implements ComboBoxModel {

    private List<Material> listaMaterial;
    private Material selection;

    public ComboBoxMaterialModel(List<Material> listaMaterial) {
        this.listaMaterial = listaMaterial;
    }

    @Override
    public int getSize() {
        return listaMaterial.size();
    }

    @Override
    public Object getElementAt(int index) {
        return listaMaterial.get(index);
    }

    @Override
    public void setSelectedItem(Object anItem) {
        selection = (Material) anItem;
    }

    @Override
    public Object getSelectedItem() {
        return selection;
    }

}
